//
//  JWModifyPassWordViewController.m
//  见闻新闻
//
//  Created by brother on 16/3/16.
//  Copyright © 2016年 JoanBoat. All rights reserved.
//

#import "JWModifyPassWordViewController.h"

#import "JWUserModel.h"

#import "JWUpUserDataTools.h"

@interface JWModifyPassWordViewController ()
@property (weak, nonatomic) IBOutlet UITextField *PassWordText;

@property (weak, nonatomic) IBOutlet UITextField *MynewPassWordText;

@property (weak, nonatomic) IBOutlet UITextField *MyNewPassWordAgain;
@end

@implementation JWModifyPassWordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)completeClick:(id)sender {
    
    
    NSString *urlPath = [baseUrl stringByAppendingString:@"/User/updatePassword"];
    
    AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];
    
    JWUserModel *user = [JWUserModel userModel];
    
    NSDictionary *parameters = @{@"user_id" : user.user_id,
                                 @"password" :self.PassWordText.text,
                                 @"newpassword" : self.MyNewPassWordAgain.text
                                 };
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    hud.labelText = @"正在修改";

    
    [manger POST:urlPath parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        [[[UIAlertView alloc] initWithTitle:@"提示" message:responseObject[@"data"] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil]show];
        if ([responseObject[@"code"] integerValue] == 1) {
            [JWUpUserDataTools updataToModel];
        }
        hud.hidden = YES;
//        NSLog(@"%@",responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"%@",error);
        
        hud.hidden = YES;
        
    }];
    
}


- (IBAction)back:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
